<!DOCTYPE html>
<html lang="zh-CN" id="html">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
    <link href="__CSS__/materialize.min.css" rel="stylesheet">
    <script src="__JS__/jquery.min.js"></script>
    <script src="__JS__/materialize.min.js"></script>
    <link href="__CSS__/engineer-index.css" rel="stylesheet">
    <title>功能选择</title>
</head>
<body>
    <div class="section bgc-blue">
        <a href="#0" class="center-a">
            <img class="responsive-img" src="__IMG__/logo.png">
        </a>
    </div>
    <div class="line"></div>
    <div class="container">
        <div class="row">
            <div class="col s12 m6 offset-m3 l6 offset-l3">
                <div class="col s4 m4">
                    <a id="scanQRCode">
                        <div class="card-panel module01 center">
                            <img class="responsive-img" src="__IMG__/report.png">
                            <br>
                            <span class="white-text">报&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;修</span>
                        </div>
                    </a>
                </div>
                <div class="col s4 m4">
                    <a id="scanQRCodea" >
                        <div class="card-panel module02 center">
                            <img class="responsive-img" src="__IMG__/repair.png">
                            <br>
                            <span class="white-text">维&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;修</span>
                        </div>
                    </a>
                </div>
                <div class="col s4 m4">
                    <a id="scanQRCodeb">
                        <div class="card-panel module03 center">
                            <img class="responsive-img" src="__IMG__/patrol.png">
                            <br>
                            <span class="white-text">巡&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;检</span>
                        </div>
                    </a>
                </div>
            </div>
        </div>
        <div class="row">
            <div class="col s12 m6 offset-m3 l6 offset-l3">
                <div class="col s4 m4">
                    <a id="scanQRCodec">
                        <div class="card-panel module04 center">
                            <img class="responsive-img" src="__IMG__/pm.png">
                            <br>
                            <span class="white-text">PM检测</span>
                        </div>
                    </a>
                </div>
                <div class="col s4 m4">
                    <a id="scanQRCoded">
                        <div class="card-panel module05 center">
                            <img class="responsive-img" src="__IMG__/performance.png">
                            <br>
                            <span class="white-text">性能检测</span>
                        </div>
                    </a>
                </div>
                <div class="col s4 m4">
                    <a href="{:U('Manage/mime')}">
                        <div class="card-panel module06 center">
                            <img class="responsive-img" src="__IMG__/mine.png">
                            <br>
                            <span class="white-text">我&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;的</span>
                        </div>
                    </a>
                </div>
            </div>
        </div>
    </div>
</body>
<?php
import("Weixin.Util.jssdk");
$jssdk = new JSSDK("wx1509e46e90775fe4", "203f4fefd0fc676e1e7c28f28a9ccec5");
$signPackage = $jssdk->GetSignPackage();
?>
<script src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js"> </script>
<script>
    wx.config({
      debug: false,
      appId: '<?php echo $signPackage["appId"];?>', 
      timestamp: <?php echo $signPackage["timestamp"];?>,
      nonceStr: '<?php echo $signPackage["nonceStr"];?>', 
      signature: '<?php echo $signPackage["signature"];?>',
      jsApiList: [
        //'checkJsApi',
        'scanQRCode',       //报修
        'scanQRCodea',      //维修
        'scanQRCodeb',      //巡检
        'scanQRCodec',      //PM检测
        'scanQRCoded',      //性能检测
      ]
    });

    wx.ready(function(){
    
      function cutstr(text,start,end){
      var s = text.indexOf(start)
      if(s>-1){
      var text2 = text.substr(s+start.length);
      var s2 = text2.indexOf(end);
      if(s2>-1){
      result = text2.substr(0,s2);
      }else result = '';
      }else result = '';
      return result;
    }

    function redirecturl(result,act){
        var serve = "http://weixin.yiyikefu.com/index.php";
        var myArray = result.split('hospid=');//2
        var devicecode = cutstr(result,'hdevice_code=','&hospid');
        var url = serve+"?m=weixin&c=manage&a=getqrcodemsg&hdevice_code="+devicecode+"&hospid="+myArray[1]+"&action="+act;
        //window.location.href = serve+"?m=weixin&c=manage&a=getqrcodemsg&hdevice_code="+devicecode+"&hospid="+myArray[1]+"&action="+act;
        $('#html').load(url);
    }


        //1.检查扫一扫接口-报修
        document.querySelector('#scanQRCode').onclick = function () {
        wx.scanQRCode({
          needResult: 1,
          desc: 'scanQRCode desc',
          success: function (res) {
            var result = res.resultStr; // 当needResult 为 1 时，扫码返回的结果
            var act = "report";
            redirecturl(result,act);
          }
        });
        };

        // //1.检查扫一扫接口-维修
        document.querySelector('#scanQRCodea').onclick = function () {
        wx.scanQRCode({
          needResult: 1,
          desc: 'scanQRCode desc',
          success: function (res) {
              var result = res.resultStr; // 当needResult 为 1 时，扫码返回的结果
              var act = "repair";
              redirecturl(result,act);
          }
        });
        };

        //巡检
        document.querySelector('#scanQRCodeb').onclick = function () {
          wx.scanQRCode({
            needResult: 1,
            desc: 'scanQRCode desc',
            success: function (res) {
              var result = res.resultStr; // 当needResult 为 1 时，扫码返回的结果
              var act = "xunjian";
              redirecturl(result,act);
            }
          });
        };

        //1.检查扫一扫接口-PM检测
        document.querySelector('#scanQRCodec').onclick = function () {
        wx.scanQRCode({
          needResult: 1,
          desc: 'scanQRCode desc',
          success: function (res) {
            var result = res.resultStr; // 当needResult 为 1 时，扫码返回的结果
            var act = "pmcheck";
            redirecturl(result,act);
          }
        });
        };

        //1.检查扫一扫接口-性能检测
        document.querySelector('#scanQRCoded').onclick = function () {
        wx.scanQRCode({
          needResult: 1,
          desc: 'scanQRCode desc',
          success: function (res) {
            var result = res.resultStr; // 当needResult 为 1 时，扫码返回的结果
            var act = "xingneng";
            redirecturl(result,act);
          }
        });
        };

// var clickevent = function(action){
//   wx.scanQRCode({
//           needResult: 1,
//           desc: 'scanQRCode desc',
//           success: function (res) {  
//         //    alert("5");
//             var result = res.resultStr; // 当needResult 为 1 时，扫码返回的结果
//             var act = action;
//             redirecturl(result,act);
//           }
//         });
// }


    });



    wx.error(function (res) {
      alert(res.errMsg);
    });
</script>
</html>